import { POST,GET } from '../utils/network.js';
import Constant from "../constant";

/**
 * 获取手机号归属地
 */
export default class Mobile {

    constructor({ mobile, success, failure }) {
        this.mobile = mobile;
        this.success = success;
        this.failure = failure;
        this.init();
    }

    init() {
        let params = {
            mobile: this.mobile,
            cmd: Constant.cmd,
            callback: Constant.PHONE_CONSTANT
        }
        GET({
            serverAddress: ENV_CONFIG.REQUEST_ADDRESS,
            url: ENV_CONFIG.URL,
            data: params
        }).then ((result) => {
            console.log(result);
            this.success(result);
        }, (err) => {
            console.log(err)
            this.failure(err);
        });
    }
}